package br.org.acessobrasil.portal.persistencia;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.org.acessobrasil.portal.modelo.Formato;

@Transactional
public class FormatoDaoSpring extends SuperDao<Formato>{

	@SuppressWarnings("unchecked")
	public List<Formato> list() {		
		return getEntityManager().createQuery("select f from Formato f").getResultList();
	}

	@Transactional(propagation=Propagation.REQUIRES_NEW,readOnly=true)
	public Formato select(Integer id) {
		return (Formato)getEntityManager().createQuery("select f from Formato f where f.nu_formato =?").setParameter(1,id).getSingleResult();
	}

	@Override
	public Formato select(Long id) {
		return select(Integer.valueOf(id.toString()));
	}

	@Transactional(propagation=Propagation.REQUIRES_NEW)
	public void create(Formato obj) throws Exception {
		super.create(obj);
	}
}
